/*
 * @Author: Dorange.Wang
 * @Date: 2021-04-12 12:19:07
 * @LastEditors: your name
 * @LastEditTime: 2021-06-07 15:44:26
 * @Description: file content
 */
import { randomString } from '@/utils/util'
export default function (processId, processName, category, description) {
  const startEventId = `Event_${randomString(8)}`
  const submitTaskId = '__initiator__'
  const flowId = `Flow_${randomString(8)}`

  const data = `
  <?xml version="1.0" encoding="UTF-8"?>
  <bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:flowable="http://flowable.org/bpmn" targetNamespace="${category}">
    <bpmn2:process id="${processId}" name="${processName}" isExecutable="true">
      <bpmn2:documentation>${description}</bpmn2:documentation>
      <bpmn2:startEvent id="${startEventId}" name="开始">
        <bpmn2:outgoing>${flowId}</bpmn2:outgoing>
      </bpmn2:startEvent>
      <bpmn2:userTask id="${submitTaskId}" name="提交节点">
        <bpmn2:incoming>${flowId}</bpmn2:incoming>
      </bpmn2:userTask>
      <bpmn2:sequenceFlow id="${flowId}" sourceRef="${startEventId}" targetRef="${submitTaskId}" />
    </bpmn2:process>
    <bpmndi:BPMNDiagram id="BPMNDiagram_1">
      <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="${processId}">
        <bpmndi:BPMNEdge id="${flowId}_di" bpmnElement="${flowId}">
          <di:waypoint x="428" y="330" />
          <di:waypoint x="560" y="330" />
          <bpmndi:BPMNLabel>
            <dc:Bounds x="478" y="312" width="33" height="14" />
          </bpmndi:BPMNLabel>
        </bpmndi:BPMNEdge>
        <bpmndi:BPMNShape id="${startEventId}_di" bpmnElement="${startEventId}">
          <dc:Bounds x="392" y="312" width="36" height="36" />
          <bpmndi:BPMNLabel>
            <dc:Bounds x="399" y="355" width="22" height="14" />
          </bpmndi:BPMNLabel>
        </bpmndi:BPMNShape>
        <bpmndi:BPMNShape id="${submitTaskId}_di" bpmnElement="${submitTaskId}">
          <dc:Bounds x="560" y="290" width="100" height="80" />
        </bpmndi:BPMNShape>
      </bpmndi:BPMNPlane>
    </bpmndi:BPMNDiagram>
  </bpmn2:definitions>
  `

  return data
}
